<?php
/**
 * egany-admin-post-type.php 
 *
 * Author URI: http://www.facebook.com/
 * @author 		PhongND
 * @category 	Admin
 * @package 	egany_discount_offer
 * @version     1.0
 */


	// add_action( 'init', 'custom_post_type', 0 );
	// add_action( 'init', array( $this, 'register_post_types' ) );
	add_action( 'init', 'register_post_types'  );
	function register_post_types()
	{
		// Periodic Discounts (periodic_discount)
		$labels = array(
			'name'                => __( 'Periodic Discounts', 'Periodic Discount General Name', 'EGANY' ),
			'singular_name'       => __( 'Periodic Discount', 'Periodic Discount Singular Name', 'EGANY' ),
			'menu_name'           => __( 'Periodic Discount', 'EGANY' ),
			'parent_item_colon'   => __( 'Parent Item:', 'EGANY' ),
			'all_items'           => __( 'All Items', 'EGANY' ),
			'view_item'           => __( 'View Periodic Discount', 'EGANY' ),
			'add_new_item'        => __( 'Add New Periodic Discount', 'EGANY' ),
			'add_new'             => __( 'Add Periodic Discount', 'EGANY' ),
			'edit_item'           => __( 'Edit Periodic Discount', 'EGANY' ),
			'update_item'         => __( 'Update Periodic Discount', 'EGANY' ),
			'search_items'        => __( 'Search Periodic Discount', 'EGANY' ),
			'not_found'           => __( 'Not found', 'EGANY' ),
			'not_found_in_trash'  => __( 'Not found in Trash', 'EGANY' ),
		);
		$args = array(
			'label'               => __( 'Periodic Discount', 'EGANY' ),
			'description'         => __( 'Periodic Discount Description', 'EGANY' ),
			'labels'              => $labels,
			'supports'            => array( ),
			'taxonomies'          => array( 'periodic_discount_category'),
			'hierarchical'        => false,
			'public'              => true,
			'show_ui'             => true,
			'show_in_menu'        => true,
			'show_in_nav_menus'   => true,
			'show_in_admin_bar'   => true,
			'menu_position'       => 5,
			'can_export'          => true,
			'has_archive'         => true,
			'exclude_from_search' => false,
			'publicly_queryable'  => true,
			'capability_type'     => 'page',
		);
		register_post_type( 'periodic_discount', $args );
		// register_taxonomy( 'periodic_discount_category',
				// 'periodic_discount',
				// array(
				// 'hierarchical'          => true,
				// // 'update_count_callback' => '_wc_term_recount',
				// 'label'                 => __( 'Periodic Discount Categories', 'EGANY'),
				// 'labels' => array(
						// 'name'              => __( 'Periodic Discount Categories', 'EGANY'),
						// 'singular_name'     => __( 'Periodic Discount Category', 'EGANY'),
						// 'menu_name'         => __( 'Categories', 'Admin menu name', 'EGANY'),
						// 'search_items'      => __( 'Search Periodic Discount Categories', 'EGANY'),
						// 'all_items'         => __( 'All Periodic Discount Categories', 'EGANY'),
						// 'parent_item'       => __( 'Parent Periodic Discount Category', 'EGANY'),
						// 'parent_item_colon' => __( 'Parent Periodic Discount Category:', 'EGANY'),
						// 'edit_item'         => __( 'Edit Periodic Discount Category', 'EGANY'),
						// 'update_item'       => __( 'Update Periodic Discount Category', 'EGANY'),
						// 'add_new_item'      => __( 'Add New Periodic Discount Category', 'EGANY'),
						// 'new_item_name'     => __( 'New Periodic Discount Category Name', 'EGANY')
					// ),
				// 'show_ui'               => true,
				// 'query_var'             => true,
				// 'rewrite'               => false,
				// // 'capabilities'          => array(
					// // 'manage_terms' => 'manage_product_terms',
					// // 'edit_terms'   => 'edit_product_terms',
					// // 'delete_terms' => 'delete_product_terms',
					// // 'assign_terms' => 'assign_product_terms',
				// // ),
				// // 'rewrite'               => array(
					// // 'slug'         => empty( $permalinks['category_base'] ) ? _x( 'product-category', 'slug', 'EGANY') : $permalinks['category_base'],
					// // 'with_front'   => false,
					// // 'hierarchical' => true,
				// // ),
			// )	
		// );

			// register_taxonomy( 'periodic_discount_category',
			// array('periodic_discount'),
				// array(
					// 'hierarchical' => true,
					// 'show_ui' => false,
					// 'query_var' => true,
					// 'rewrite' => false,
				// )
			// );


		
		// //Discount Offer Line (discount_offer_line)
		// $labels = array(
			// 'name'                => __( 'Discount Offer Lines', 'Discount Offer Line General Name', 'EGANY' ),
			// 'singular_name'       => __( 'Discount Offer Line', 'Discount Offer Line Singular Name', 'EGANY' ),
			// 'menu_name'           => __( 'Discount Offer Line', 'EGANY' ),
			// 'parent_item_colon'   => __( 'Parent Item:', 'EGANY' ),
			// 'all_items'           => __( 'All Items', 'EGANY' ),
			// 'view_item'           => __( 'View Item', 'EGANY' ),
			// 'add_new_item'        => __( 'Add New Item', 'EGANY' ),
			// 'add_new'             => __( 'Add New', 'EGANY' ),
			// 'edit_item'           => __( 'Edit Item', 'EGANY' ),
			// 'update_item'         => __( 'Update Item', 'EGANY' ),
			// 'search_items'        => __( 'Search Item', 'EGANY' ),
			// 'not_found'           => __( 'Not found', 'EGANY' ),
			// 'not_found_in_trash'  => __( 'Not found in Trash', 'EGANY' ),
		// );
		// $args = array(
			// 'label'               => __( 'Discount Offer Line..', 'EGANY' ),
			// 'description'         => __( 'Discount Offer Line Description', 'EGANY' ),
			// 'labels'              => $labels,
			// 'supports'            => array( ),
			// 'taxonomies'          => array( 'asdasd' ),
			// 'hierarchical'        => false,
			// 'public'              => true,
			// 'show_ui'             => true,
			// 'show_in_menu'        => true,
			// 'show_in_nav_menus'   => true,
			// 'show_in_admin_bar'   => true,
			// 'menu_position'       => 5,
			// 'can_export'          => true,
			// 'has_archive'         => true,
			// 'exclude_from_search' => false,
			// 'publicly_queryable'  => true,
			// 'capability_type'     => 'page',
		// );
		// register_post_type( 'discount_offer_line', $args );

		
		// Validation Period (validation_period) 
		$labels = array(
			'name'                => __( 'Validation Periods', 'Validation Period General Name', 'EGANY' ),
			'singular_name'       => __( 'Validation Period', 'Validation Period Singular Name', 'EGANY' ),
			'menu_name'           => __( 'Validation Period', 'EGANY' ),
			'parent_item_colon'   => __( 'Parent Validation Period:', 'EGANY' ),
			'all_items'           => __( 'All Validation Periods', 'EGANY' ),
			'view_item'           => __( 'View Validation Period', 'EGANY' ),
			'add_new_item'        => __( 'Add New Validation Period', 'EGANY' ),
			'add_new'             => __( 'Add New', 'EGANY' ),
			'edit_item'           => __( 'Edit Validation Period', 'EGANY' ),
			'update_item'         => __( 'Update Validation Period', 'EGANY' ),
			'search_items'        => __( 'Search Validation Period', 'EGANY' ),
			'not_found'           => __( 'Not found', 'EGANY' ),
			'not_found_in_trash'  => __( 'Not found in Trash', 'EGANY' ),
		);
		$args = array(
			'label'               => __( 'Validation Period', 'EGANY' ),
			'description'         => __( 'Validation Period Description', 'EGANY' ),
			'labels'              => $labels,
			'supports'            => array( ),
			'taxonomies'          => array(), // array( 'validation_period_category', 'post_tag' ),
			'hierarchical'        => false,
			'public'              => true,
			'show_ui'             => true,
			'show_in_menu'        => true,
			'show_in_nav_menus'   => true,
			'show_in_admin_bar'   => true,
			'menu_position'       => 5,
			'can_export'          => true,
			'has_archive'         => true,
			'exclude_from_search' => false,
			'publicly_queryable'  => true,
			'capability_type'     => 'page',
		);
		register_post_type( 'validation_period', $args );


	
	}
	





add_action('admin_menu', 'egany_discount_offer_menu');
function egany_discount_offer_menu() {

	// $main_page = add_menu_page( __( 'WooCommerce', 'EGANY'), __( 'WooCommerce', 'EGANY'), 'manage_woocommerce', 'woocommerce', null, null, '55.5' );

	// add_submenu_page( 'woocommerce', __( 'WooCommerce Add-ons/Extensions', 'EGANY'),  __( 'Add-ons', 'EGANY') , 'manage_woocommerce', 'wc-addons', array( $this, 'addons_page' ) );

	
	
	//create new top-level menu
	add_menu_page(__('Discount Offer', 'EGANY' ), __('Discount Offer', 'EGANY' ), 'manage_options',  'edit.php?post_type=periodic_discount', null, plugins_url('/assets/images/logo.png', EGANY_PLUGIN_FILE) );
	
	
	// add_submenu_page( 'egany_discount_offer_page', __( 'EGANY Add-ons/Extensions', 'EGANY' ),  __( 'Add-ons', 'EGANY' )  , 'manage_options', 'egany_addons_page', array( $this, 'addons_page' ) );
	
	
	
//***
// add sub menu page , with post-type.... edit.php?post_type=
/* add post meta 
========
 <?php add_post_meta($post_id, $meta_key, $meta_value, $unique); ?> 

get box meta
update/save box meta
========
backend, show data: manage post custom colum

========

*/





	//ADD SUB MENU
	// $all_item=newsjam_getall_data();    
	// if(is_array($all_item))
	// {        
		// foreach($all_item as $item)
		// {            
			// if($item->hidemenu == 'on'){
				// remove_menu_page( 'edit.php?post_type='.$item->custom_type );                
			// }
			// add_submenu_page('egany_discount_offer_handle', __($item->name,'EGANY' ), __($item->name,'EGANY' ), 'manage_options', $item->custom_type, 'news_jam_submenu_settings_page');            
		// }
	// }
	
	
	//call register settings function
	// add_action( 'admin_init', 'register_mysettings' ); 
	
		
}